package pl.edu.agh.mobilne;

import java.util.Random;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

public class Reminder extends BroadcastReceiver{
	
	@Override
	public void onReceive(Context context, Intent intent) {
		try {
			NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
			Notification notification = new Notification(R.drawable.pillicon, "It's time for medical action.", System.currentTimeMillis());
			
			CharSequence contentTitle = "Medical notification";
			CharSequence contentText = "It's time for medical action!";
			Intent notificationIntent = new Intent(context, MedicalDevDataReciver.class);
			notificationIntent.putExtra("scenario", intent.getStringExtra("scenario"));
			PendingIntent contentIntent = PendingIntent.getActivity(context, new Random().nextInt(), notificationIntent, 0);

			notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
			notification.flags |= Notification.FLAG_AUTO_CANCEL;
			notificationManager.notify(1, notification);
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

}
